package review;

public class 最长重复子串 {

    public String deputile(String str) {
        char[] chars = str.toCharArray();

        int start = 0;
        int end = 0;
        int maxStart = 0;
        int maxEnd = 0;
        for (int i = 1; i < chars.length; i++) {
            if(chars[i] != chars[i - 1]) {
                end = i;
                int lenTemp = end - start;
                if(lenTemp > (maxEnd - maxStart)) {
                    maxStart = start;
                    maxEnd = end;
                }
                start = end;
            }
        }
        return str.substring(maxStart,maxEnd);
    }

    public static void main(String[] args) {

    }
}
